import { defineStore } from 'pinia'
import Api from '../util/axios'

export const useService = defineStore('service', {
	state: () => ({ data: {}, datasource: {}, groups: {} }),
	actions: {
		async init_metadata() {
			await Api.post('/show_datasource').then((res) => {
				res.forEach(element => {
					this.datasource[element.id] = element.name
				});
			})
			await Api.post('/get_group').then((res) => {
				res.forEach(element => {
					this.groups[element.id] = element.name
				});
			})
		}
	},
})